package com.hwadee.hello.advice;

import java.util.Arrays;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.stereotype.Component;

@Component
public class HijackAroundMethod implements MethodInterceptor {

	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {
		Object obj = null;
		try {
			System.out.println("之前:" + invocation.getMethod().getName() + "-->");
			System.out.println(Arrays.toString(invocation.getArguments()));
			
			obj = invocation.proceed();
			
			System.out.println("返回之后:" + obj);
		} catch (Exception e) {
			System.out.println(invocation.getMethod().getName() + "抛出异常" + e.getMessage());
		}
		return obj;
	}

}
